# Define the package name and dependencies
LINUX_DEPENDENCIES += u-boot-tools arm-trusted-firmware

# Define the build steps
define LINUX_S32_HSE_VERIFIEDBOOT_BUILD_CMD
    ESCAPED_DTB_PATH=$(echo $(KERNEL_DEVICETREE) | sed 's/\//\\\//g'); \
    sed -e "\
        s/<kernel_image>/arch\/arm64\/boot\/Image/g; \
        s/<dtb_blob>/arch\/arm64\/boot\/dts\/$${ESCAPED_DTB_PATH}/g \
    " $(HOST_DIR)/etc/keys/verifiedboot/s32.its > $(@D)/s32_updated.its; \
    $(HOST_DIR)/bin/mkimage -f $(@D)/s32_updated.its -k $(HOST_DIR)/etc/keys/verifiedboot/ -r $(@D)/kernel.itb
endef
LINUX_POST_BUILD_HOOKS += LINUX_S32_HSE_VERIFIEDBOOT_BUILD_CMD

# Define the install steps
define LINUX_S32_VERIFIEDBOOT_INSTALL_TARGET_CMD
    install -m 0644 $(@D)/kernel.itb $(TARGET_DIR)/boot/
endef
LINUX_POST_INSTALL_TARGET_HOOKS += LINUX_S32_VERIFIEDBOOT_INSTALL_TARGET_CMD

# Define the deploy steps
define LINUX_VERIFIEDBOOT_INSTALL_IMAGES_CMDS
    cp $(@D)/kernel.itb $(BINARIES_DIR)/
endef

